<%--
  Created by IntelliJ IDEA.
  User: dell
  Date: 2019/7/9
  Time: 15:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="true" %>
<html>
<head>
    <title>Title</title>
    <base href="<%=request.getContextPath()%>/"/>
    <%@include file="/publs.jsp"%>
    <script>
        var cxk="<%=request.getContextPath()%>";
    </script>
</head>
<body>
<div id="root">

    <modal title="调拨记录" v-model="record" width="850">
        <i-table :data="recordData" :columns="recordColumns" :height="500"></i-table>
    </modal>

    <modal title="添加调库单" @on-ok="doUpdNum" v-model="allocationModal" width="650">
        <i-form :label-width="80">
            <row>
                <i-col span="10">
                    <form-item label="调出仓库:">
                        <i-select v-model="allocation.recall" @on-change="searchTerm(allocation.recall)">
                            <i-option v-for="item in ku" :value="item.wid" :key="item.wid">{{item.wname}}</i-option>
                        </i-select>
                    </form-item>
                </i-col>
                <i-col span="10">
                    <form-item label="调入仓库:">
                        <i-select v-model="allocation.callin">
                            <i-option v-for="item in ku" :value="item.wid" :key="item.wid">{{item.wname}}</i-option>
                        </i-select>
                    </form-item>
                </i-col>
            </row>
            <row>
                <i-col span="10">
                    <form-item label="药品名称:">
                        <i-select v-model="allocation.drugsId">
                            <i-option v-for="item in drugSelect" :value="item.drugsid" :key="item.drugsid">{{item.drugsName}}</i-option>
                        </i-select>
                    </form-item>
                </i-col>
                <i-col span="10">
                    <form-item label="调拨数量:">
                        <Input-Number type="text" v-model="allocation.number" :min="1" value="1"/>
                    </form-item>
                </i-col>
            </row>
        </i-form>
    </modal>


    <card style="text-align: center"><h2>库存调拨</h2></card>
    <row>
        <i-col span="2" style="margin-left: 15px">
            <i-button type="primary" icon="md-add" @click="openModal">添加调库单</i-button>
        </i-col>
        <i-col span="2" style="margin-left: 15px">
            <i-button type="info" icon="md-search" @click="searchAll">全部仓库</i-button>
        </i-col>
        <i-col span="4" style="margin-left: 10px">
            <i-button type="success" icon="ios-barcode" @click="searchRecord">调拨记录</i-button>
        </i-col>
    </row>
    <div style="border: solid 5px #F8F8F9;width: 99%;margin: 10px auto">
        <Split v-model="split1">
            <div slot="left" class="demo-split-pane">
                <tree :data="treeData" @on-select-change="treeChange"></tree>
            </div>
            <div slot="right" class="demo-split-pane">
                <i-table  :data="tableDate" :columns="columns" border stripe :height="800"></i-table>
            </div>
        </Split>
    </div>
</div>




<script>
    new Vue({
        el:"#root",
        data:{
            split1:0.3,
            treeDate:[],
            tableDate:[],
            tableDateyaomincehgn:[],
            ku:[],
            columns:[
                {title:"编号", key:"drugsid", sortable:true},
                {title:"药品名称", key:"drugsName", tooltip:true},
                {title:"单价/元", key:"price"},
                {title:"数量", key:"number"},
                {title:"单位", key:"companyids"},
                {title:"所在仓库",key:"wname"}
            ],
            allocationModal:false,
            allocation:{number:1},
            drugSelect:[],
            treeData:[],
            record:false,
            recordData:[],
            recordColumns:[
                {title:"编号",key:"alloId"},
                {title:"调出仓库",key:"wname"},
                {title:"调入仓库",key:"waName"},
                {title:"调拨药品",key:"drugsName"},
                {title:"调拨数量",key:"drugsNumber"},
                {title:"调拨时间",key:"allDate"}
            ]
        },
        methods:{
            searchAll(){
                axios.get(`${cxk}/check/treeData`)
                    .then(({data})=>{
                        this.treeData=data.obj;
                    })
                axios.get(`${cxk}/kucun/searchDrug`)
                    .then(({data})=>{
                        this.tableDate = data.obj;
                    });
            },
            openModal(){
                this.allocationModal = true;
            },
            searchTerm(wid){
                axios.get(`${cxk}/kucun/searchTerm`,{params:{wId:wid}})
                    .then(({data})=>{
                        console.log(data.obj)
                        this.drugSelect=data.obj;
                    });
            },
            doUpdNum(){
                axios.post(`${cxk}/kucun/doUpdNum`,this.allocation)
                    .then(({data})=>{
                        iview.Message.warning(data.msg)
                        this.searchAll();
                    });
            },
            treeChange(a,b){
                axios.get(`${cxk}/check/searchBitId?bitId=${b.id}`)
                    .then(({data})=>{
                        this.tableDate = data.obj;
                    })
            },
            searchWare(){
                axios.get(`${cxk}/kucun/searchWare`)
                    .then(({data})=>{
                        this.ku = data.obj;
                    })
            },
            serchAlls(){
                axios.get(`${cxk}/kucun/searchDrug`)
                    .then(({data})=>{
                        this.tableDateyaomincehgn = data.obj;
                    });
            },
            searchRecord(){
                this.record = true;
                axios.get(`${cxk}/kucun/searchRecord`)
                    .then(({data})=>{
                        this.recordData = data.obj;
                    })
            }
        },
        mounted(){
            this.serchAlls();
            this.searchWare();
            this.searchAll();
        }
    })
</script>

</body>
</html>
